home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / include / gsl / gsl_permutation.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-04-20  |  2.9 KB  |  97 lines

  1. /* permutation/gsl_permutation.h
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef __GSL_PERMUTATION_H__
  21. #define __GSL_PERMUTATION_H__
  22.  
  23. #include <stdlib.h>
  24. #include <gsl/gsl_errno.h>
  25.  
  26. #undef __BEGIN_DECLS
  27. #undef __END_DECLS
  28. #ifdef __cplusplus
  29. # define __BEGIN_DECLS extern "C" {
  30. # define __END_DECLS }
  31. #else
  32. # define __BEGIN_DECLS /* empty */
  33. # define __END_DECLS /* empty */
  34. #endif
  35.  
  36. __BEGIN_DECLS
  37.  
  38. struct gsl_permutation_struct
  39. {
  40.   size_t size;
  41.   size_t *data;
  42. };
  43.  
  44. typedef struct gsl_permutation_struct gsl_permutation;
  45.  
  46. gsl_permutation *gsl_permutation_alloc (const size_t n);
  47. gsl_permutation *gsl_permutation_calloc (const size_t n);
  48. void gsl_permutation_init (gsl_permutation * p);
  49. void gsl_permutation_free (gsl_permutation * p);
  50. int gsl_permutation_memcpy (gsl_permutation * dest, const gsl_permutation * src);
  51.  
  52. int gsl_permutation_fread (FILE * stream, gsl_permutation * p);
  53. int gsl_permutation_fwrite (FILE * stream, const gsl_permutation * p);
  54. int gsl_permutation_fscanf (FILE * stream, gsl_permutation * p);
  55. int gsl_permutation_fprintf (FILE * stream, const gsl_permutation * p, const char *format);
  56.  
  57. size_t gsl_permutation_size (const gsl_permutation * p);
  58. size_t * gsl_permutation_data (const gsl_permutation * p);
  59.  
  60. size_t gsl_permutation_get (const gsl_permutation * p, const size_t i);
  61. int gsl_permutation_swap (gsl_permutation * p, const size_t i, const size_t j);
  62.  
  63. int gsl_permutation_valid (gsl_permutation * p);
  64. void gsl_permutation_reverse (gsl_permutation * p);
  65. int gsl_permutation_inverse (gsl_permutation * inv, const gsl_permutation * p);
  66. int gsl_permutation_next (gsl_permutation * p);
  67. int gsl_permutation_prev (gsl_permutation * p);
  68.  
  69. #ifdef GSL_EXPORTS
  70. __declspec(dllexport) int gsl_check_range;
  71. #elif defined(GSL_IMPORTS)
  72. __declspec(dllimport) int gsl_check_range;
  73. #else
  74. extern int gsl_check_range;
  75. #endif
  76.  
  77. #ifdef HAVE_INLINE
  78.  
  79. extern inline
  80. size_t
  81. gsl_permutation_get (const gsl_permutation * p, const size_t i)
  82. {
  83. #ifndef GSL_RANGE_CHECK_OFF
  84.   if (i >= p->size)
  85.     {
  86.       GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0);
  87.     }
  88. #endif
  89.   return p->data[i];
  90. }
  91.  
  92. #endif /* HAVE_INLINE */
  93.  
  94. __END_DECLS
  95.  
  96. #endif /* __GSL_PERMUTATION_H__ */
  97.